package cn.bugstack.config;

import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class OkhttpClientConfig {
    @Bean
    public OkHttpClient okHttpClient(){
        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(15, TimeUnit.SECONDS)
                .readTimeout(60,TimeUnit.SECONDS)
                .writeTimeout(15,TimeUnit.SECONDS)
                .connectionPool(new ConnectionPool(10,5,TimeUnit.MINUTES))
                .retryOnConnectionFailure(true)
                .build();
        return client;
    }
}
